<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<%=basePath%>">
		<!-- jsp文件头和头部 -->
		<jsp:include page="../js_top.jsp"/>
		<style>
		.center a{width:185px;height:38px;line-height:38px;-webkit-border-radius:5px;border-radius:5px;border:#b7bacb;display:block;font-size:14px;font-family:"微软雅黑";text-shadow:0 0px 0 rgba(0,0,0,0)!important;background:#b7bacb url(img/table_report_icon.png) no-repeat 70px center;float:right;text-align:center;color:#fff;cursor:pointer;text-indent:20px;}
		.center a:first-child{margin:10px 90px 0 0;}
		.center a:last-child{margin:10px 0 0 90px;float:left;background:#b7bacb url(/static/img/images/table_report_icon1.png) no-repeat 70px center;}
		.center a:hover{background-color:#0fb1d6;text-decoration:none;}
		</style>
	</head>
	
<body>
	<div style="height:300px;overflow-y:auto;    width: 307px;margin: 0 0 0 107px;">
		<div>
			<ul id="tree" class="ztree" style="overflow:auto;width:60%;margin: 0 auto;"></ul>
		</div>
		<!-- 
		<div id="loading" class="center" style="display:none">
			<br/><br/><br/><br/><img src="plugins/aceAdmin/images/jiazai.gif" /><br/><h4 class="lighter block green"></h4>
		</div>
		 -->
	</div>
	
	<footer>
		<div style="width: 100%;" class="center">
			<a onclick="top.Dialog.close();">取消</a>
			<a onclick="save();">确定</a>
		</div>
	</footer>
	
	<script type="text/javascript">
	//$(top.hangge());
	var zTree;
	var setting = {
			check: {
				enable: true
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};

		var zNodes =${zTreeNodes};
		
		function setCheck() {
			zTree = $.fn.zTree.getZTreeObj("tree"),
			type = { "Y" : "p", "N" : "s" };
			zTree.setting.check.chkboxType = type;
			
		}
		
		$(document).ready(function(){
			$.fn.zTree.init($("#tree"), setting, zNodes);
			setCheck();
		});
		
		function save(){
				var nodes = zTree.getCheckedNodes();
				var tmpNode;
				var ids = "";
				for(var i=0; i<nodes.length; i++){
					tmpNode = nodes[i];
					if(i!=nodes.length-1){
						ids += tmpNode.id+",";
					}else{
						ids += tmpNode.id;
					}
				}
				var id = ${id};
				var url = '<%=basePath%>sys/sysRole/saveRoleMenu.do';
				var postData;
				postData = {"roleId":id,"menuIds":ids};
				$("#loading").show();
				$.post(url,postData,function(data){
					if(data && data=="success"){
						$("#loading").hide();
						top.Dialog.close();
					}
				});
			 
		 }
	</script>
	
	
</body>
</html>